/**
 * html+ 串口蓝牙操作
 */
let sppBle = sppBle || {}
sppBle.BluetoothTool = (address)=> {
	let BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
	let Intent = plus.android.importClass("android.content.Intent");
	let IntentFilter = plus.android.importClass("android.content.IntentFilter");
	let BluetoothDevice = plus.android.importClass("android.bluetooth.BluetoothDevice");
	
	let BluetoothSocket = plus.android.importClass("android.bluetooth.BluetoothSocket");
	let UUID = plus.android.importClass("java.util.UUID");
	
	//连接串口设备的 UUID
	let MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

	let invoke = plus.android.invoke;
	let btAdapter = BluetoothAdapter.getDefaultAdapter();
	let activity = plus.android.runtimeMainActivity();
    let device = invoke(btAdapter, "getRemoteDevice", address);
    let btSocket = invoke(device, "createRfcommSocketToServiceRecord", MY_UUID);
	setTimeout(()=>{
		btSocket.close();
	},1000)
}
	
export default sppBle